package io.gitee.wminyu.day02;

import java.util.Scanner;

public class gcd {
    public static void main(String[] args) {

        System.out.println("请输入两个整数");
        Scanner input = new Scanner(System.in);
        int numble1 = input.nextInt();
        int numble2 = input.nextInt();
        System.out.println("最大公约数为：" );
        System.out.println(getGcd(numble1, numble2));
        System.out.println("最小公倍数为：" );
        System.out.println(getLcm(numble1,numble2));
    }
    //求最大公约数
    public static int  getGcd(int num1, int num2) {
        int temp, gcd;
        while (num1 > 0) {
            temp = num2 % num1;
            num2 = num1;
            num1 = temp;
        }
        gcd = num2;
        return gcd;
    }
    //求最小公倍数
    public static int  getLcm(int num1, int num2) {
        int lcm;
        lcm = (num1*num2)/getGcd(num1,num2);
        return lcm;
    }
}